package com.contacts.action;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.contacts.biz.impl.UserBizImpl;
import com.contacts.model.Contact;

/**
 * Servlet implementation class SerchContact
 */
public class SerchContact extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private UserBizImpl bimpl = new UserBizImpl();       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SerchContact() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		int uid = Integer.parseInt(request.getParameter("uid"));
		String cname = request.getParameter("cname");
		Contact tac = bimpl.serchContact(cname,uid);
		
		request.setAttribute("tac", tac);
		request.getRequestDispatcher("jsp/showSerchContact.jsp").forward(request, response);
		
		
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
